﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

namespace ProjectSem40701.Admin
{
    public partial class Award : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void AwardStatusLabel_DataBinding(object sender, EventArgs e)
        {
            try
            {
                Label AwardStatusLabel=sender as Label;
                AwardStatusLabel.Text = AwardStatusLabel.Text == "1" ? "Kích hoạt" : "Khóa";
            }
            catch
            { 
            
            }
        }

        protected void cbbStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                DropDownList cbbStatus = sender as DropDownList;
                if (cbbStatus.SelectedValue.ToString() != "-1")
                {
                    this.rgrAward.MasterTableView.GetColumn("AwardStatus").CurrentFilterValue = cbbStatus.SelectedValue;
                    GridFilteringItem filterItem = this.rgrAward.MasterTableView.GetItems(GridItemType.FilteringItem)[0] as GridFilteringItem;
                    filterItem.FireCommandEvent("Filter", new Pair("EqualTo", "AwardStatus"));
                }
                else
                {
                    GridFilteringItem filterItem = this.rgrAward.MasterTableView.GetItems(GridItemType.FilteringItem)[0] as GridFilteringItem;
                    filterItem.FireCommandEvent("Filter", new Pair("NoFilter", "AwardStatus"));
                }
                //this.lblSelectedIndex.Text = cbbStatus.SelectedValue.ToString();
            }
            catch (Exception exc)
            {
                exc.ToString();
            }
        }

        protected void cbbStatus_PreRender(object sender, EventArgs e)
        {
            DropDownList cbbStatus = (DropDownList)sender;
            foreach (ListItem item in cbbStatus.Items)
            {
                item.Selected = true;
                //if (item.Value.ToString() == this.lblSelectedIndex.Text.ToString())
                //{
                //    item.Selected = true;
                //}
            }
        }

        protected void lblStatus_DataBinding(object sender, EventArgs e)
        {
            Label lblStatus = (Label)sender;
            if (lblStatus.Text == "1")
            {
                lblStatus.Text = "Kích hoạt";
            }
            else
            {
                lblStatus.Text = "Khóa";
            }
        }

        protected void AwardDescriptionLabel_DataBinding(object sender, EventArgs e)
        {
            Label lblAwardDescription = (Label)sender;
            lblAwardDescription.Text = Server.HtmlDecode(lblAwardDescription.Text);
        }
    }
}
